<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue实例生命周期函数</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        {{test}}
    </div>

    <script>
        //生命周期函数就是vue实例，在某一个时间点会自动执行的函数
        var vm = new Vue({
            el: '#app',
            template: "<div>{{test}}</div>",
            data: {
                test: "hello test"
            },
            beforeCreate: function() {
                console.log('beforeCreate');
            },
            created: function() {
                console.log('created');
            },
            beforeMount: function() {
                console.log(this.$el);
                console.log('beforeMount');
            },
            mounted: function() {
                console.log(this.$el);
                console.log('mounted');
            },
            beforeDestroy: function() {
                console.log(this.$el);
                console.log('beforeDestroy');
            },
            destroyed: function() {
                console.log(this.$el);
                console.log('destroyed');
            },
            beforeUpdate: function() {
                console.log(this.$el);
                console.log('deforeUpdate');
            },
            updated: function() {
                console.log(this.$el);
                console.log('updated');
            },
        })
    </script>
</body>
</html>